Explanation:

At the start of a new phase we generate and normalize a new direction vector. The variable perc keeps track of which step we are in the interpolation so it is reinitialised to 0.